package com.nengchuan.eic.nceconomy.controller;

import com.github.pagehelper.PageInfo;
import com.nengchuan.eic.nceconomy.constant.SwFileComputeStatusEnum;
import com.nengchuan.eic.nceconomy.entity.dto.SwFilePageDTO;
import com.nengchuan.eic.nceconomy.entity.dto.SwGimCallBackDTO;
import com.nengchuan.eic.nceconomy.entity.po.SwFile;
import com.nengchuan.eic.nceconomy.entity.vo.SwFileVO;
import com.nengchuan.eic.nceconomy.service.SwFileService;
import com.nengchuan.eic.nceconomy.service.SwFileServiceImpl;
import com.nengchuan.model.model.WrappedResult;
import com.nengchuan.util.NullCheckUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 功能描述:
 *
 * @Author: liurui
 * @Date: 2020/6/4 0004 上午 10:24
 */
@Api(value = "三维测算文件--交互接口", tags = "三维测算文件--交互接口")
@RestController
@RequestMapping("/sw_gim")
public class SwGimCallBackController {

    @Autowired
    private SwFileService swFileService;

    @ApiOperation("gim生成gfc/xml回调接口")
    @PostMapping("/call_back")
    public WrappedResult callBack(SwGimCallBackDTO dto) {
        if(NullCheckUtils.isNull(dto.getSignId())||NullCheckUtils.isNull(dto.getStatus())){
            return WrappedResult.fail("signId、status必填");
        }
        SwFile swFile = swFileService.getById(dto.getSignId());
        if(swFile==null){
            return WrappedResult.fail("不存在该业务id");
        }
        swFile.setStatus(dto.getStatus());
        swFile.setOssUrl(dto.getOssUrl());
        swFileService.updateById(swFile);
        return WrappedResult.success();
    }
}
